package cn.wolfcode.wolf2w.business.listener;


import cn.wolfcode.wolf2w.business.api.domain.StrategyCanal;
import com.alibaba.fastjson.JSON;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;


@Component
@CanalTable("ta_strategy")
public class StrategyListener implements EntryHandler<StrategyCanal> {

    @Autowired
    private AmqpTemplate amqpTemplate;
    @Override
    public void insert(StrategyCanal strategyCanal) {
        String jsonString = JSON.toJSONString(strategyCanal);
        //发送rabbitmq消息，添加canal后发送
        amqpTemplate.convertAndSend("strategyExchange", "strategy.insert", jsonString);
        System.out.println(strategyCanal);
    }
}
